<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>教练添加</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../css/okadmin.css">
</head>

<body>
<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
    <ul class="layui-tab-title">
        <li class="layui-this">添加用户</li>
        <li>批量添加用户</li>
    </ul>
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>教练添加</legend>
    </fieldset>
    <div class="layui-tab-content" style="height: 100px;">
        <div class="layui-tab-item layui-show">
            <div class="addtea-con">
                <div class="from-con">
                    <div style="width: 60%;margin: 0 auto;">
                        <form class="layui-form" style="margin-left: -90px" action="" id="formaddtea">
                            <div class="layui-row">
                                <div class="layui-col-xs6">
                                    <div class="layui-form-item" style="margin-right: 15%">
                                        <label class="layui-form-label">I&#12288;&#12288;&#12288;D</label>
                                        <div class="layui-input-block">
                                            <input id="coachId" name="coachId" type="text"
                                                   style="float: left;position: relative;" lay-verify="required"
                                                   placeholder="请输入账号名" class="layui-input" autocomplete="off">
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-xs6">
                                    <div class="layui-form-item" style="margin-left: 15%">
                                        <label class="layui-form-label">姓&#12288;&#12288;名</label>
                                        <div class="layui-input-block">
                                            <input id="fullname" name="fullname" type="text"
                                                   style="float: left;position: relative;" class="layui-input"
                                                   placeholder="请输入姓名" lay-verify="required" autocomplete="off">
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-row">
                                <div class="layui-col-xs6">
                                    <div class="layui-form-item" style="margin-right: 15%">
                                        <label class="layui-form-label">电&#12288;&#12288;话</label>
                                        <div class="layui-input-block">
                                            <input id="phone" name="phone" type="tel"
                                                   style="float: left;position: relative;" class="layui-input"
                                                   placeholder="请输入电话号码" autocomplete="off">
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-xs6">
                                    <div class="layui-form-item" style="margin-left: 15%">
                                        <label class="layui-form-label">性&#12288;&#12288;别</label>
                                        <div class="layui-input-block" name="agender" id="agender">
                                            <input type="radio" name="agender" id="agender0" value="0" title="女" checked>
                                            <input type="radio" name="agender" id="agender1" value="1" title="男">
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-row">
                                <div class="layui-col-xs6">
                                    <div class="layui-form-item" style="margin-right: 15%">
                                        <label class="layui-form-label">邮&#12288;&#12288;箱</label>
                                        <div class="layui-input-block ">
                                            <input id="email" name="email" type="text" style="float: left;position: relative;"
                                                   class="layui-input"
                                                   placeholder="请输入邮箱"  autocomplete="off">
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-xs6">
                                    <div class="layui-form-item" style="margin-left: 15%">
                                        <label class="layui-form-label">车&#12288;&#12288;辆</label>
                                        <div class="layui-input-block ">
                                            <select name="vehicle" id="vehicle" style="float: left;position: relative;" lay-search>
                                                <option value=''>暂时不选择</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-row">
                                <div class="layui-col-xs6">
                                    <div class="layui-form-item" style="margin-right: 15%">
                                        <label class="layui-form-label">教学科目</label>
                                        <div class="layui-input-block ">
                                            <select name="teachingStage" id="teachingStage" style="float: left;position: relative;"
                                                    lay-verify="teachingStage">
                                                <option value="1">科目一</option>
                                                <option value="2">科目二</option>
                                                <option value="3">科目三</option>
                                                <option value="4">科目四</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-xs6">
                                    <div class="layui-form-item" style="margin-left: 15%">
                                        <label class="layui-form-label">是否被选</label>
                                        <div class="layui-input-block ">
                                            <select name="isStartChoice" id="isStartChoice" style="float: left;position: relative;"
                                                    lay-verify="isStartChoice">
                                                <option value="0">未开始被选</option>
                                                <option value="1">开始被选</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-row">
                                <div class="layui-col-xs6">
                                    <div class="layui-form-item" style="margin-right: 15%">
                                        <label class="layui-form-label">最大学员数</label>
                                        <div class="layui-input-block ">
                                            <select name="choiceCountMax" id="choiceCountMax" style="float: left;position: relative;"
                                                    lay-verify="choiceCountMax">
                                                <option value="1">1</option>
                                                <option value="2">2</option>
                                                <option value="3" selected>3</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-xs6">
                                    <div class="layui-form-item" style="margin-left: 15%;">
                                        <label class="layui-form-label">入职时间</label>
                                        <div class="layui-input-block " style="width: 76%;">
                                            <input id="joiningTime" name="joiningTime" type="text" style="float: left;position: relative;"
                                                   class="layui-input" autocomplete="off">
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item" style="padding-bottom: 90px">
                                <div class="layui-input-block">
                                    <button type="button" id="addParent" lay-submit="" lay-filter="addParent"
                                            class="layui-btn" style="float: right;margin-top: 50px"> 保 存
                                    </button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-tab-item">
            <div class="importTeacher">
                <div class="layui-block importTeacher-con">
                    <div class="layui-form-item">
                        <button type="button" class="layui-btn leftbtn" id="test4">
                            <i class="layui-icon"></i>选择Excel文件
                        </button>
                        <a href="../../templateDownload/教练信息导入模板.xlsx" type="reset"
                           class="layui-btn layui-btn-primary rightbtn">下载模板</a>
                    </div>
                </div>
                <table class="layui-hide" id="teacher"></table>
                <div class="model">
                    <script type="text/html" id="toolbarDemo">
                        <label>导入失败的数据</label>
                    </script>
                    <table class="layui-hide" id="teacherData"></table>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<!--js逻辑-->
<script src="../../lib/layui/layui.js"></script>
<script src="../../js/jquery.min.js"></script>
<script src="../../js/application.js"></script>
<script>
    //用户信息导入
    layui.use(['element', 'okLayer','form','laydate'], function () {
        var $ = layui.jquery;
        var okLayer = layui.okLayer;
        var element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块
        var form = layui.form;
        let laydate = layui.laydate;
        //日期
        laydate.render({
            elem: '#joiningTime',
            trigger: 'click'
        });
        form.render();

        $("#test4").on('click', excelImport);

        function excelImport() {
            okLayer.open("用户信息导入", "coachImport.html", "90%", "90%", null, function () {

            });
        }
        $("#addParent").on("click",function (){
            if($('#coachId').val()==""||$('#fullname').val()==""){
                return;
            }
            layer.confirm("确定添加此教练信息?", function (index) {
                var teachingStage = $("#teachingStage").find("option:checked").val();//教学科目
                var isStartChoice = $("#isStartChoice").find("option:checked").val();//是否被选
                var choiceCountMax = $("#choiceCountMax").find("option:checked").val();//最大学员数
                var vehicle = $("#vehicle").find("option:checked").val();//车辆
                var data = {
                    coachId: $('#coachId').val(),
                    fullname: $('#fullname').val(),
                    phone: $('#phone').val(),
                    email: $('#email').val(),
                    agender: $('input[name="agender"]:checked').val(),
                    joiningTime: $("#joiningTime").val(),
                    teachingStage: teachingStage,
                    isStartChoice: isStartChoice,
                    choiceCountMax: choiceCountMax,
                    vehicleId: vehicle
                };
                showloading(true)
                myAjax(mainUri + "/coach/insert", data, function (d) {
                    if (d.code == "0") {
                        layer.msg(d.msg)
                    } else {
                        alert(d.msg)
                    }
                })
                showloading(false)
            })
        })

        myAjax(mainUri + '/vVehicle/selects', {page: -1,isFree:1}, function (datas) {
            var list = datas['data'];
            var option;
            for (var i = 0; i < list.length; i++) {
                {
                    option += "<option value='" + list[i]['vehicleId'] + "'>" + list[i]['vehicleName'] + "</option>";
                }
            }
            $("#vehicle").append(option);
            form.render();
        })
    });

</script>
</html>